/**
 * @program: LeetCode
 * @description: LeetCode : 剑指 Offer II 006. 排序数组中两个数字之和
 * @author: WXY
 * @create: 2022-12-11 20:13
 * @Version 1.0
 **/


public class Num_offer2_006_twoSum {
    public static int[] twoSum(int[] numbers, int target) {
        int left = 0;
        int right = numbers.length - 1;
        while (left < right) {
            if (numbers[left] + numbers[right] < target) {
                left++;
            } else if (numbers[left] + numbers[right] > target) {
                right--;
            } else {
                break;
            }
        }
        return new int[]{left, right};
    }
}
